package com.ydcycloud.log.dao.impl;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.smart.mvc.dao.hibernate.JdbcDao;
import com.smart.mvc.model.Pagination;
import com.ydcycloud.log.dao.SysLogDao;
import com.ydcycloud.log.model.SysLog;
import com.ydcycloud.sys.dao.impl.BaseDaoImpl;

@Repository
public class SysLogDaoImpl extends BaseDaoImpl<SysLog, Integer> implements SysLogDao{

	@Resource
	private JdbcDao baseJdbcDao;
	/**
	 * 
	 * 加载系统日志列表
	 * 
	 * @Description: TODO
	 * @param @param pageNo 当前页数
	 * @param @param pageSize 每一页的航行数
	 * @param @return   
	 * @return Pagination<Map<String,Object>>  
	 * @throws
	 * @author yzw
	 * @date 2016年12月2日
	 */
	@Override
	public Pagination<Map<String, Object>> findPagination(Integer pageNo,
			Integer pageSize) {
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT a.id, "
				+ "a.log_content AS logContent,a.type,a.operate_ip AS operateIp, "
				+ "a.param_value AS paramValue,a.param_name AS paramName, "
				+ "a.create_by AS createBy,create_date AS createDate "
				+ "FROM t_sys_log AS a "
				+ "ORDER BY a.id DESC ");
		Pagination<Map<String, Object>> p=new Pagination<Map<String, Object>>(pageNo, pageSize);
		baseJdbcDao.pageSqlMapQuery(p, sql.toString());
		return p;
	}
	
	/**
	 * 
	 * 清空全部日志
	 * 
	 * @Description: TODO
	 * @return void  
	 * @throws
	 * @author yzw
	 * @date 2016年12月2日
	 */
	@Override
	public void logDel() {
		StringBuffer sql = new StringBuffer();
		sql.append("truncate table t_sys_log ");
		baseJdbcDao.executeUpdate(sql.toString());
		
	}

}
